package com.amos.web;

import com.amos.base.base.Result;
import com.amos.base.redis.RedisClient;
import com.amos.base.util.ResultWapper;
import com.amos.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 用户类
 */
@RestController
@RequestMapping(value = "/account")
public class AccountController {

    @Autowired
    AccountService accountService;

    @Autowired
    RedisClient client;
    @RequestMapping("/{id}")
    public Result load(@PathVariable("id") String id){
        return ResultWapper.SUCCESS(accountService.load(id));
    }

    @RequestMapping(value = "/redis/{key}/{value}")
    public Result saveIntoRedis(@PathVariable("key") String key, @PathVariable("value") Object value){
        String val = "从客户端传入的值为："+value;
        client.set(key,val);
        return ResultWapper.SUCCESS(client.getByKey(key));
    }
}
